#ifndef _COMMON_OPERATION_H
#define _COMMON_OPERATION_H

#include <string>
#include <vector>
#include "Message.h"

using namespace std;



class CommonOperation{
	public:
		typedef int (*Method)(Message & message);
		typedef struct{
			int optID;
			Method method;
		}OptMethod;
		typedef struct{
			string attributeID;
			vector <OptMethod *> methodList;
		}AttributeMethod;
		

		CommonOperation();
		~CommonOperation();

		void addMethodToList(string attributeID,int optID,Method method);
		int execute(Message &message);

		bool remove(const string attributeID);
		bool remove(const string attributeID,const int optID);
	private:
		vector <AttributeMethod *> _attributeMethodList;

		Method getMethod(vector <OptMethod *> *optMethodList,const int optID);
		vector <OptMethod *>::iterator find(vector <OptMethod *> *optMethodList,const int optID);

		vector <OptMethod *> *getMethodList(const string attributeID);
		vector <AttributeMethod *>::iterator find(const string attributeID);

		bool remove(vector <AttributeMethod *>::iterator it,const int optID);
};


#endif //#ifndef _COMMON_OPERATION_H

